<template>
	<view class="u-wrap" @click="bodyClick()">
		<u-navbar safeAreaInsetTop fixed placeholder bgColor='#3c9cff' leftIconColor='#fff'>
			<view slot="center" class="textTitle">
				房源信息
			</view>
			<view slot="right" class="rightTitle">
				<u-icon class="firstIcon" name="wifi" color="#fff"></u-icon>
				<u-icon name="eye" color="#fff" @click="goChange"></u-icon>

			</view>
			<view slot="left" class="leftTitle" @click.stop="showNameClick">

				<u-icon name="list-dot" color="#fff"></u-icon>

				<view class="popupClass" v-if="showName">
					<view class="modal-ang"></view>
					<view class="modal-item" @click="showNo">
						<text class="textClass u-border-bottom">推盘</text>
						<text class="textClass u-border-bottom">预销控</text>
						<text class="textClass u-border-bottom" @click="goSetting">设置</text>
						<text class="textClass" @click="goStatistics">统计</text>
					</view>
				</view>

			</view>

		</u-navbar>
		<view class="u-menu-wrap" v-if="showList">

			<u-cell-group :border='false'>
				<u-cell icon="star" title="哥伦布时代广场-一号楼" :isLink="true"></u-cell>

			</u-cell-group>
			<view class="isLeft">
				<u-icon name="eye"></u-icon>
				<u-scroll-list :indicator="false">

					<u--text @click='getChange(index)' class="tagClass" :class="isActive===index?'active':''"
						:color="isActive===index?'#fff':'#909399'" size='24rpx' margin='0 20rpx 0 0' :lines="1"
						v-for="(item, index) in [1,2,3,4,5,6,7,8,9,9,9,9,9,9]" :key="index" text="一单元住宅广场" block>
					</u--text>
					<view class="viewContent">占</view>
				</u-scroll-list>
			</view>

		
				<scroll-view scroll-y scroll-x scroll-with-animation class="resourceTop" :style="{'height':navTopHeight +'px'}">

					<view class="class-item" v-for="(item , index) in tabbar" :key="index">

						<view class="item-title">
							<text>{{item.name}}</text>
						</view>
						<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1">
							<u-button @click="goDetail(item1)" type="primary" size="mini">{{item1.name}}</u-button>

						</view>
						<view class="viewContent">占</view>

					</view>

				</scroll-view>
		


		</view>

		<view v-if="!showList">

			<resourceList></resourceList>
		</view>

		<u-popup :show="show" mode="center" closeable @close="() => show = false">
			<ring-echarts></ring-echarts>
		</u-popup>


	</view>
</template>

<script>
	import classifyData from '@/utils/classify.data.js';
	import resourceList from '@/pages/resource/resourceList.vue'
	import ringEcharts from '@/components/resource/ringEcharts.vue'
	export default {
		data() {
			return {
				showList: true,
				tabbar: classifyData,
				navTopHeight: null,
				showName: false,
				show: false,
				isActive: 0,
				title: '请选择要切换的身份',
				content: 'uView的目标是成为uni-app生态最优秀的UI框架',

			}
		},
		components: {
			resourceList,
			ringEcharts
		},
		onPageScroll() {
			this.showName = false
		},
		onReady() {
			this.setNavTop()
		},
		methods: {
			setNavTop() {
				// uniapp的方法
				let _this = this

				uni.getSystemInfo({
					success: function(res) { // res - 各种参数
						const query = uni.createSelectorQuery().in(_this);

						query.select('.resourceTop').boundingClientRect(function(
							data) { // data - 各种参数

							_this.navTopHeight = res.windowHeight - data.top -
								10 // 到屏幕顶部的距离
						}).exec()
					}
				})

			},
			getChange(index) {
				this.isActive = index
			},
			goDetail() {
				this.show = true
			},
			goChange() {
				this.showList = !this.showList
			},
			bodyClick() {
				this.showName = false
			},
			showNameClick() {
				this.showName = !this.showName
			},
			goSetting() {
				uni.navigateTo({
					url: '/pages/resource/resourceSetting'
				});
			},
			goStatistics() {
				uni.navigateTo({
					url: '/pages/resource/resourceStatistics'
				});
			}

		}
	}
</script>
<style lang="scss">

</style>
<style lang="scss" scoped>
	.viewContent {
		width: 80rpx;
		height: 20rpx;
		color: #fff;

	}

	.u-menu-wrap {
		background-color: #fff;

		.isLeft {
			position: relative;
			padding-left: 90rpx;
			margin-top: 20rpx;
			margin-bottom: 20rpx;

			/deep/ .u-icon {
				position: absolute;
				left: 20rpx;
				top: 5px;
			}

			/deep/ .u-scroll-list {
				padding-bottom: 0px;
			}

			.tagClass {
				background: #ecf5ff;
				padding: 10rpx;
				border-radius: 10rpx;

				/deep/ .u-text__value {
					width: 100rpx;
				}

			}

			.active {
				background: #3c9cff;
			}
		}
	}

	.textTitle {
		font-size: 16px;
		color: #fff;
	}

	.leftTitle {
		position: relative;

		.popupClass {
			position: absolute;
			left: -4px;
			top: 24px;

			.modal-ang {
				position: absolute;
				background-color: #060607;
				width: 10px;
				height: 10px;
				top: -4px;
				left: 6px;
				transform: rotate(45deg);
				border-radius: 2px;
				z-index: 10;
			}

			.modal-item {
				background-color: #060607;
				width: 60px;
				padding: 2px 7px;
				font-size: 12px;
				position: relative;
				color: #fff;
				flex: 1;
				z-index: 20;
				border-radius: 5px;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: center;
			}

			.textClass {
				width: 100%;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
			}
		}
	}

	.rightTitle {
		display: flex;

		.firstIcon {
			margin-right: 5px;
		}
	}

	.class-item {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: flex-start;
		position: relative;
		background: #fff;



		.item-title {
			position: sticky;
			left: 0;
			// width: 80rpx;
			height: 110rpx;
			background: #f6f6f6;
			box-sizing: border-box;
			font-size: 26rpx;
			color: #444;
			font-weight: 400;
			display: flex;
			justify-content: center;
			align-items: center;
			flex: 0 0 80rpx;
			z-index: 10;



		}

		.thumb-box {
			margin-left: 10rpx;
			margin-right: 10rpx;

		}
	}
</style>
